
import http, { baseParams } from "@/utils/request";
import { UrlSaveAduid } from "@/utils/apiUrl";
import { getAreaInfo } from "@/utils/storage";
import { getZoneRealTime } from "./zone";
import { setZoneArea } from "./getZoneArea";


//类型：申请成功
export const SAVE_ADUID_REQ_SUCCESS = "SAVE_ADUID_REQ_SUCCESS"

//类型：申请失败
export const SAVE_ADUID_REQ_FAIL = "SAVE_ADUID_REQ_FAIL"

/**
 * 保存aduid
 * @returns thunk
 */
export const saveAduid = () => {
    return async (dispatch) => {
        getZoneRealTime(async (result, zonePath) => {
            // 更新状态
            dispatch(setZoneArea(zonePath));

            //组装参数
            const params = baseParams()

            //发起请求
            const res = await http.post(zonePath + UrlSaveAduid, params)
            const resCode = parseInt(res.code)
            console.log("保存aduid回调-：" + resCode)
            console.log("保存aduid回调-结束：=======")
        });
    }
}